<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="keywords" content="${bdictionarySPageInfo[1].name }">
<meta name="description" content="${bdictionarySPageInfo[2].name }">
<title>${bdictionarySPageInfo[0].name }</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/resources/front/css/bootstrap.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/resources/front/css/public.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/resources/front/css/font-awesome.css" />
<link rel="stylesheet"	href="${pageContext.request.contextPath }/resources/front/css/choose.css" />
<%-- <link rel="stylesheet"	href="${pageContext.request.contextPath }/resources/front/css/choose_footer.css" />	  --%>
</head>

<body>
<div id="allAdverti" style="display:none">
	<c:forEach items="${banner5_list}" var="item">
			${item }
	</c:forEach>
	<c:forEach items="${banner6_list}" var="item">
			${item }
	</c:forEach>
</div>
	<%@ include file="header_choose.jsp"%>
	<div class="all-bd">
		<div class="advier" id="adbanner5"></div>
		<div class="sift">
			<div class="kg">
				<span>展开选项</span> <img
					src="${pageContext.request.contextPath }/resources/front/img/open.png"
					alt="" />
			</div>
			<div class="first-title">
				<div class="channel">频道</div>
				<ul class="channel-style">
					<li class="li-choose" id="quan">全部</li>
					<c:forEach items="${requestScope.channels_list}" var="item"
						varStatus="i">
						<li code="${item.code}">${item.name }</li>
					</c:forEach>
				</ul>
			</div>
			<div class="second-title">
				<!--<div class="selectNumberScreen">-->
				<div id="selectList" class="screenBox screenBackground">
					<dl id="address" class="listIndex" attr="terminal_brand_s">
						<dt>地区</dt>
						<dd>
							<a href="javascript:void(0)" class="a-choose">全部</a>
							<input type="hidden" value="${area }" id="area-chos">
							<c:forEach items="${requestScope.address_list }" var="item"
								varStatus="i">
								<a href="javascript:void(0)" code="${item.code}">${item.name }</a>
							</c:forEach>
						</dd>
					</dl>
					<dl id="types" class="listIndex" attr="价格范围">
						<dt>类型</dt>
						<dd>
							<a href="javascript:void(0)" class="a-choose">全部</a>
							<c:forEach items="${requestScope.type_list}" var="item"
								varStatus="i">
								<a href="javascript:void(0)" code="${item.code}">${item.name }</a>
							</c:forEach>
						</dd>
					</dl>
					<dl id="years" class=" listIndex" attr="terminal_os_s">
						<dt>年份</dt>
						<dd>
							<a href="javascript:void(0)" class="a-choose">全部</a>
							<c:forEach items="${requestScope.year_list}" var="item"
								varStatus="i">
								<a href="javascript:void(0)" code="${item.code}">${item.name}</a>
							</c:forEach>
						</dd>
					</dl>
					<dl id="videoClaritys" class=" listIndex"
						attr="terminal_activity_s">
						<dt>清晰度</dt>
						<dd>
							<a href="javascript:void(0)" class="a-choose">全部</a> <a
								href="javascript:void(0)" code="H360P">标清</a> <a
								href="javascript:void(0)" code="H720P">高清</a> <a
								href="javascript:void(0)" code="H1080P">超清</a>
						</dd>
					</dl>
					<div class="hasBeenSelected">
						<dl>
							<dt>已选择</dt>
							<dd style="display: none" class="clearDd">
								<div class="clearList"></div>
								<div class="eliminateCriteria">共<span id="sums">0</span>条筛选结果</div>
							</dd>
						</dl>
					</div>
				</div>

				<!--</div>-->
			</div>
		</div>
		<div class="enjoy">
			<div class="sort">排序</div>
			<ul class="sort-style" id="sort-one">
				<input type="hidden" value="${sort }" id="sort-chos">
				<li class="li-x" code="create_time">最新上映</li>
				<li code="like_count">人气</li>
			</ul>
			<ul class="only">

			</ul>
			<ul class="only" style='display: none'>
			</ul>
			
		</div>
		<div style="clear:both;"></div>
		<div class="cpage" style="display:none">
		<div  class="sort-more"  onclick="loadData(this)">
			<input type="text" id="pagecount" style="display:none;" value="0">
			<a href="javascript:void(0);" style="padding-left:26px;display:block;width:170px;height:40px;line-height:31px;font-size:21px;font-family:'微软雅黑'">加载更多+</a>
		</div>
		</div>
		<div class="advier" id="adbanner6">fdsfdsfds</div>
	</div>
	  <!--footer-->
	    <%@ include file="footer.jsp"%>
</body>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/resources/front/js/jquery-2.2.3.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/resources/front/js/shaixuan.js"></script>

<script type="text/javascript"
	src="${pageContext.request.contextPath }/resources/front/js/pageUtil.js"></script>
<script>
	var isFirstLoad=false;
	var type='${type}';
	
	$(document)
			.ready(
					function() {
						$(document).scroll(function() {
							if ($(document).scrollTop() > 380) {
								$('.header').addClass('hearder-position');
								$('.nav').show();
							} else {
								$('.header').removeClass('hearder-position');
								$('.nav').hide();
								$('.nav-list').hide()
							}
						})
						$('.nav').click(function() {
							$('.nav-list').toggle();
						});
						//添加频道事件
						$(document).on(
								"click",
								".channel-style li",
								function() {
									$(this).addClass('li-choose').siblings()
											.removeClass('li-choose');
								});

						$(document).on(
								"click",
								'.sort-style li',
								function() {
									$(this).addClass('li-x').siblings()
											.removeClass('li-x');
								});
						$('.sort-style li').each(
								function(index) {
									$(this).click(
											function() {
												$(this).addClass('li-x')
														.siblings()
														.removeClass('li-x');
												$(".only").css({
													"display" : "none"
												});
												$(".only").eq(index).css({
													"display" : "block"
												});
											})
								})
						$('.kg')
								.click(
										function() {
											$('.second-title').toggle();
											if ($('.second-title').css(
													'display') == 'block') {
												$('.kg span').html('收起选项');
												$('.kg img')
														.attr('src',
																'${pageContext.request.contextPath }/resources/front/img/close.png');
												$('.kg').css('bottom', '10px')
											} else {
												$('.kg span').html('展开选项');
												$('.kg img')
														.attr('src',
																'${pageContext.request.contextPath }/resources/front/img/open.png');
												$('.kg').css('bottom', '25px')
											}
										})

						$('.only li').each(function(index) {
							index = (index + 1) * 5 - 1;
							$('.only li').eq(index).addClass('li-none');
						});
						/* if ($(".only li").length < 15) {
							$(".sort-more").hide();
						} else {
							$(".sort-more").show();
						} */
						//搜索显示
						$('.kg').click();
                        
					})
</script>

<script type="text/javascript">
	$(function() {
		//本地路径
		var prefix = "${pageContext.request.contextPath }";
		var code = $(this).attr("code");
		console.info(code);
		/*  findTypesByCode(prefix + "/public/findTypes.html", {
			"code" : code
		});  */
		
		
		var i =1;
		//当点击鼠标时,隐藏或显示
		$(".channel-style li").bind(
				"click",
				function() {
					if(!isFirstLoad){
						//alert(isFirstLoad);
						  $("#address dd a").eq(0).click();
						  $("#types dd a").eq(0).click();
						  $("#years dd a").eq(0).click();
						  $("#videoClaritys dd a").eq(0).click();
						  $("#sort-one li").eq(0).click(); 
						}
					//获取code的值
					var code = $(this).attr("code");
					//多能用到code
					console.info(code);
					  findTypesByCode(prefix + "/public/findTypes.html", {
						"code" : code
					});
				
					var params = {};
					params["name"] = $("#search-input").val();
					params["channel"] = $(this).attr("code");
					params["area"] = $("#address dd .a-choose").attr("code");
					params["type"] = $("#types dd .a-choose").attr("code");
					params["year"] = $("#years dd .a-choose").attr("code");
					params["videoClaritys"] = $("#videoClaritys dd .a-choose")
							.attr("code");
					params["sort"] = $("#sort-one .li-x").attr("code");
					/* alert(params["type"]); */
					 if(i>1){
						 $(".selectedShow").hide();
						 params["type"] = $("#types dd .a-choose").attr("cod");
						/*  delete params.type;  */
					}  
					i++;
					search(prefix + "/public/searchBSeries.html", params);
				
				});
		
		$("#search").bind(
				"click",
				function() {
					var params = {};
					params["name"] = $("#search-input").val();
					params["channel"] = $(".channel-style .li-choose").attr(
							"code");
					params["area"] = $("#address dd .a-choose").attr("code");
					params["type"] = $("#types dd .a-choose").attr("code");
					params["year"] = $("#years dd .a-choose").attr("code");
					params["videoClaritys"] = $("#videoClaritys dd .a-choose")
							.attr("code");
					params["channelName"]= $(".channel-style .li-choose").text();
					params["areaName"]= $("#address dd .a-choose").text();
					params["typeName"]= $("#types dd .a-choose").text();
					params["videoCName"]= $("#videoClaritys dd .a-choose").text();
					params["sort"] = $("#sort-one .li-x").attr("code");
					search(prefix + "/public/searchBSeries.html", params);
				});

		$(document).on(
				"click",
				"#types dd a",
				function() {
					var params = {};
					params["channelName"]= $(".channel-style .li-choose").text();
					params["areaName"]= $("#address dd .a-choose").text();
					params["typeName"]= $("#types dd .a-choose").text();
					params["videoCName"]= $("#videoClaritys dd .a-choose").text();
					params["name"] = $("#search-input").val();
					params["channel"] = $(".channel-style .li-choose").attr(
							"code");

					params["area"] = $("#address dd .a-choose").attr("code");
					params["type"] = $(this).attr("code");
					params["year"] = $("#years dd .a-choose").attr("code");
					params["videoClaritys"] = $("#videoClaritys dd .a-choose")
							.attr("code");
					params["sort"] = $("#sort-one .li-x").attr("code");
					search(prefix + "/public/searchBSeries.html", params);
				});

		$("#address dd a").bind(
				"click",
				function() {
					var params = {};
					params["channelName"]= $(".channel-style .li-choose").text();
					params["areaName"]= $("#address dd .a-choose").text();
					params["typeName"]= $("#types dd .a-choose").text();
					params["videoCName"]= $("#videoClaritys dd .a-choose").text();
					params["name"] = $("#search-input").val();
					params["channel"] = $(".channel-style .li-choose").attr(
							"code");

					params["area"] = $(this).attr("code");
					params["type"] = $("#types dd .a-choose").attr("code");
					params["year"] = $("#years dd .a-choose").attr("code");
					params["videoClaritys"] = $("#videoClaritys dd .a-choose")
							.attr("code");
					params["sort"] = $("#sort-one .li-x").attr("code");
					search(prefix + "/public/searchBSeries.html", params);
				});

		$("#years dd a").bind(
				"click",
				function() {
					var params = {};
					params["channelName"]= $(".channel-style .li-choose").text();
					params["areaName"]= $("#address dd .a-choose").text();
					params["typeName"]= $("#types dd .a-choose").text();
					params["videoCName"]= $("#videoClaritys dd .a-choose").text();
					params["name"] = $("#search-input").val();
					params["channel"] = $(".channel-style .li-choose").attr(
							"code");

					params["area"] = $("#address dd .a-choose").attr("code");
					params["type"] = $("#types dd .a-choose").attr("code");
					params["year"] = $(this).attr("code");
					params["videoClaritys"] = $("#videoClaritys dd .a-choose")
							.attr("code");
					params["sort"] = $("#sort-one .li-x").attr("code");
					search(prefix + "/public/searchBSeries.html", params);
				});

		$("#videoClaritys dd a").bind("click", function() {
			var params = {};
			params["name"] = $("#search-input").val();
			params["channel"] = $(".channel-style .li-choose").attr("code");
			params["channelName"]= $(".channel-style .li-choose").text();
			params["areaName"]= $("#address dd .a-choose").text();
			params["typeName"]= $("#types dd .a-choose").text();
			params["videoCName"]= $("#videoClaritys dd .a-choose").text();
			params["area"] = $("#address dd .a-choose").attr("code");
			params["type"] = $("#types dd .a-choose").attr("code");
			params["year"] = $("#years dd .a-choose").attr("code");
			params["videoClaritys"] = $(this).attr("code");
			params["sort"] = $("#sort-one .li-x").attr("code");
			search(prefix + "/public/searchBSeries.html", params);
		});
		
		$(".sort-style li").bind("click", function() {
			var params = {};
			params["name"] = $("#search-input").val();
			params["channel"] = $(".channel-style .li-choose").attr("code");
			params["channelName"]= $(".channel-style .li-choose").text();
			params["areaName"]= $("#address dd .a-choose").text();
			params["typeName"]= $("#types dd .a-choose").text();
			params["videoCName"]= $("#videoClaritys dd .a-choose").text();
			params["area"] = $("#address dd .a-choose").attr("code");
			params["type"] = $("#types dd .a-choose").attr("code");
			params["year"] = $("#years dd .a-choose").attr("code");
			params["videoClaritys"] = $("#videoClaritys dd .a-choose")
			.attr("code");
			params["sort"] = $(this).attr("code");
			search(prefix + "/public/searchBSeries.html", params);
		});

		var selectedShow = $(".selectedShow");

		selectedShow.eq(0).find("em").on(
				"click",
				function() {
					var params = {};
					params["name"] = $("#search-input").val();
					params["channel"] = $(".channel-style .li-choose").attr(
							"code");

					params["type"] = $("#types dd .a-choose").attr("code");
					params["year"] = $("#years dd .a-choose").attr("code");
					params["videoClaritys"] = $("#videoClaritys dd .a-choose")
							.attr("code");
					params["sort"] = $("#sort-one .li-x").attr("code");
					search(prefix + "/public/searchBSeries.html", params);
				});

		selectedShow.eq(1).find("em").on(
				"click",
				function() {
					var params = {};
					params["name"] = $("#search-input").val();
					params["channel"] = $(".channel-style .li-choose").attr(
							"code");

					params["area"] = $("#address dd .a-choose").attr("code");
					params["year"] = $("#years dd .a-choose").attr("code");
					params["videoClaritys"] = $("#videoClaritys dd .a-choose")
							.attr("code");
					params["sort"] = $("#sort-one .li-x").attr("code");
					search(prefix + "/public/searchBSeries.html", params);
				});

		selectedShow.eq(2).find("em").on(
				"click",
				function() {
					var params = {};
					params["name"] = $("#search-input").val();
					params["channel"] = $(".channel-style .li-choose").attr(
							"code");

					params["area"] = $("#address dd .a-choose").attr("code");
					params["type"] = $("#types dd .a-choose").attr("code");
					params["videoClaritys"] = $("#videoClaritys dd .a-choose")
							.attr("code");
					params["sort"] = $("#sort-one .li-x").attr("code");
					search(prefix + "/public/searchBSeries.html", params);
				});

		selectedShow.eq(3).find("em").on("click", function() {
			var params = {};
			params["name"] = $("#search-input").val();
			params["channel"] = $(".channel-style .li-choose").attr("code");

			params["area"] = $("#address dd .a-choose").attr("code");
			params["type"] = $("#types dd .a-choose").attr("code");
			params["year"] = $("#years dd .a-choose").attr("code");
			params["sort"] = $("#sort-one .li-x").attr("code");
			search(prefix + "/public/searchBSeries.html", params);
		});
		
		if(type!=null){
			var typeStrs=type.split('_');
			isFirstLoad=true;
			$("li[code='"+typeStrs[0]+"']").trigger("click");
		}
		
		
		//条件查询
		var searchInput = '${name}';
		$('#search').click();
		document.onkeypress = function(e) {
			var ev = document.all ? window.event : e;
			if (ev.keyCode == 13) {
				var searchVal = $("#search-input").val();
				if (searchVal != null && searchVal != "") {
					$('#search').click();
				}
			}
		};
	});
	//点击关键词
	function searchKeywords(obj){
		var key=$(obj).text();
		$("#search-input").val(key);
		$("#search").click();
	}
	//添加选中的条件
	function findTypesByCode(url, params) {

		$.post(url, params, function(json) {
			$("#types dd a").remove();
			var appendStr = "";
			appendStr = appendStr
					+ '<a href="javascript:void(0)" class="a-choose">全部</a>';
			$(json).each(
					function(i, item) {
						appendStr = appendStr
								+ '<a href="javascript:void(0)" code="'
								+ item.code + '">' + item.name + '</a>';
					});
			$("#types dd").append(appendStr);
			
			
		}, "json");
	}

	function search(url, params) {
		$.post(
						url,
						params,
						function(json) {
							$(".only a").remove();
							$("#pagecount").val(0);
							$(json.list).each(
											function(i, item) {
												var ind = "<a href='${pageContext.request.contextPath }/common/redirect?id="
													+ item.id
													+ "&source="+item.source+"'><li ";
												if((i+1)%5==0){
													ind+="class='li-none'";
												}
												ind+="><img src='${baseImgPath}"+item.cover+"' alt='"+item.name+"' /><p class='c-title'>"
												+ item.name
												+ "</p><p class='c-word'>";
												if(item.description!=null){ind+= item.description}
												ind+= "</p><span class='bj'>独播</span></li></a>";
												$(".only")
														.append(
																ind);
												
												if(isFirstLoad){
													//alert("1");
													isFirstLoad=false;
													//alert(type);
													if (type.indexOf("_")!=-1) {
														$("a[code='"+type+"']").click();
													}else{
														var $sort = $("#sort-chos").val();
														if ($sort!=null) {
															$("li[code='"+$sort+"']").trigger("click");
														}
														var $area = $("#area-chos").val();
														if($area!=null){
															$("a[code='"+$area+"']").trigger("click");
														}
													}
												}
											});
						$(".only li").hover(
								function(){
									$(this).children("p").css("color","#ED7500");
								  	$(this).append(" <div class='run-long'></div>");
								  	$('.run-long').append('<img src="${pageContext.request.contextPath }/resources/front/img/run.png" alt="" />')			    
								  },function(){
									$(this).children("p").css("color","");
								  	$(this).remove(".run-long");
								  	$('.run-long').remove();
								  }
										); 
							var tt=$(".c-title");
							var end="${totalPageCount}";
							if($(".end").length>0 || tt.length<20 || json.pageNo==0){	
								$(".cpage").hide();}else{$(".cpage").show();}
							var sum = json.length;
							$("#sums").html(sum);
						}, "json");
		return;
	}
	/* function initpage(itemCount){
		$(".cpage").tzPage(itemCount, {
			num_edge_entries : 0, //边缘页数
			num_display_entries :4, //主体页数
			num_edge_entries:5,
			current_page:0,
			showGo:true,
			showSelect:true,
			items_per_page : 20, //每页显示X项
			prev_text : "前一页",
			next_text : "后一页",
			callback : function(pageNo,psize){//回调函数
				loadData(pageNo,psize);
				
			
			}
		});
	} */
	function loadData(obj){
		$this=$(obj);
		var params = {};
		var scount=0;
		$("#pagecount").val($("#pagecount").val()-1+2);
		params["channelName"]= $(".channel-style .li-choose").text();
		params["areaName"]= $("#address dd .a-choose").text();
		params["typeName"]= $("#types dd .a-choose").text();
		params["videoCName"]= $("#videoClaritys dd .a-choose").text();
		params["pageNo"] = $("#pagecount").val();
		params["pSize"] = 20;
		params["name"] = $("#search-input").val();
		params["channel"] = $(".channel-style .li-choose").attr(
				"code");
		params["area"] = $("#address dd .a-choose").attr("code");
		params["type"] = $("#types dd .a-choose").attr("code");
		params["year"] = $("#years dd .a-choose").attr("code");
		params["videoClaritys"] = $("#videoClaritys dd .a-choose")
				.attr("code");
		params["sort"] = $("#sort-one .li-x").attr("code");
		$.ajax({
			type:"post",
			url:"${pageContext.request.contextPath }/public/searchPage.html",
			data:params,
			success:function(data){
				$(".only").append(data);
				var tt=$(".c-title");
				if($(".end").length>0){
					$(".cpage").hide();
					$(".end").remove();
				}
				
			}
		});
	}
	
	 $("#adbanner5").ready(function(){
     	adLoopTime("banner5");
     });
	$("#adbanner6").ready(function(){
			adLoopTime("banner6");
     });
	
	function adLoopTime(obj){
    	var banner1=$("."+obj);
		var length=banner1.length;
		if(banner1.eq(0).attr("status")=='null' || banner1.eq(0).attr("status")=='none' || length==0){
			$("#ad"+obj).css("display","none");
		}else{
			var interval=banner1.eq(0).attr("interval");
			if(length==1){
			var src=banner1.eq(0).find("img").attr("src");
			var basepath="${baseImgPath}";
			banner1.eq(0).find("img").attr("src",basepath+src);
			$("#ad"+obj).html(banner1.eq(0).prop("outerHTML"));
			banner1.eq(0).find("img").attr("count",interval);
			var i=0;
			setInterval(function(){ 
				if(i%interval==0){
    				var count=banner1.eq(0).find("img").attr("count");
    				banner1.eq(0).find("img").attr("count",parseInt(count)+parseInt(interval));
    			}
				i++
				if(i%300==0){
					adTimeInsert(banner1.eq(0).find("img"));
					banner1.eq(0).find("img").attr("count","0");
				}
			},1000);
			}else if(length>1){
				var i=0;
				var j=0;
				var basepath="${baseImgPath}";
				var src=banner1.eq(j%length).find("img").attr("src");
				banner1.eq(j%length).find("img").attr("src",basepath+src);
				$("#ad"+obj).html(banner1.eq(j%length).prop("outerHTML"));
				banner1.eq(0).find("img").attr("count",interval);
        		setInterval(function(){
        			if(i<length && i!=0){
	        			var src=banner1.eq(i%length).find("img").attr("src");
	        			src=banner1.eq(i%length).find("img").attr("src");
	        			banner1.eq(i%length).find("img").attr("src",basepath+src);
	        			
	        			}
        			i++;
        			if(i%interval==0){
        				j++
        				var count=banner1.eq(j%length).find("img").attr("count");
        				banner1.eq(j%length).find("img").attr("count",parseInt(count)+parseInt(interval));
        				$("#ad"+obj).html(banner1.eq(j%length).prop("outerHTML"));
        			}
					if(i%300==0){
        				for(var t=0;t<banner1.length;t++){
        					adTimeInsert(banner1.eq(t).find("img"));
        					banner1.eq(t).find("img").attr("count","0");
        				}
						
					} 
					
					
        		},1000);
        		
        	}
		}
    }
  
    
   
    function adTimeInsert(obj){
    	var $this=$(obj);
    	var params={};
    	params["adpositionCode"]=$this.attr("pcode");
    	params["adpositionName"]=$this.attr("pname");
    	params["adResourceId"]=$this.attr("adid");
    	params["adResourceTitle"]=$this.attr("adtitle");
    	params["adTypeName"]=$this.attr("adtypename");
    	params["adTypeCode"]=$this.attr("adtype");
    	params["type"]="b";
    	params["count"]=$this.attr("count");
    	$.ajax({
			type:"post",
			async: false,
			data:params,
			url:"${pageContext.request.contextPath }/public/addAdRecord.html",
			
		});
    }
    function wordsinsert(obj){
    	var $this=$(obj);
    	var params={};
    	params["adpositionCode"]=$this.attr("pcode");
    	params["adpositionName"]=$this.attr("pname");
    	params["adResourceId"]=$this.attr("adid");
    	params["adResourceTitle"]=$this.attr("adtitle");
    	params["adTypeName"]=$this.attr("adtypename");
    	params["adTypeCode"]=$this.attr("adtype");
    	params["type"]="d";
    	params["count"]="1";
    	$.ajax({
			type:"post",
			async: false,
			data:params,
			url:"${pageContext.request.contextPath }/public/addAdRecord.html",
			
		});
    }

</script>
</html>

